﻿#define MySql
#undef MSSql
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
using System.Text.RegularExpressions;
using MySql.Data.MySqlClient;
using System.Text;

namespace ukeasbjWeb
{
    public partial class Search_Leads : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Bt_OK_Click(object sender, EventArgs e)
        {
            //string action = "";
            string qq = TextBox_qq.Text.Trim();
            string phone = TextBox_phone.Text.Trim(); 
            ///string fixedPhone = "";
            string email = TextBox_Email.Text.Trim();
            string wechatNo = TextBox_wechatNo.Text.Trim();
            //action = Request["action"];
            //qq = Request["qq"];
            //phone = Request["phone"];
            //fixedPhone = Request["fixedPhone"];
            //email = Request["email"];
            //wechatNo = Request["wechatNo"];
            //phone = "18801735732";
            string sSql = "select Name_Inquirer,Name_Receptionist,Counsellor,Office,Type_Contact,Channel_Customer2Know,Date_Register from leads WHERE 1=1 And ( ";
            {/// 设置过滤条件
                if (!string.IsNullOrEmpty(phone))
                {
                    sSql = sSql + " Tel_Inquirer ='" + phone + "'";
                }
                else
                {
                    sSql = sSql + " Tel_Inquirer = 'no' ";
                }
                if (!string.IsNullOrEmpty(qq))
                {
                    sSql = sSql + " Or QQMSN_Inquirer ='" + qq + "'";
                }
                if (!string.IsNullOrEmpty(wechatNo))
                {
                    sSql = sSql + " Or QQMSN_Inquirer ='" + wechatNo + "'";
                }
                /*if (!string.IsNullOrEmpty(fixedPhone))
                {
                    sSql = sSql + " Or Tel_Inquirer='" + fixedPhone + "'";
                }*/
                if (!string.IsNullOrEmpty(email))
                {
                    sSql = sSql + " Or Email_Inquirer ='" + email + "'";
                }

            }
            
            sSql = sSql + " ) LIMIT 0,1";
            MySqlConnection MySqlconn = new MySqlConnection();
            MySqlDataReader MysqlReader = Common_SXD.Open_MySqlDataReader(sSql, MySqlconn, "打开数据库出错：", Response);
            int nCol = 0;
            StringBuilder sb = new StringBuilder();
            if (MysqlReader  != null)
            {
                while (MysqlReader.Read() && MysqlReader.FieldCount > 0)
                {
                    nCol++;
                    ///HtmlTableRow row = new HtmlTableRow();
                    string Name_Inquirer = MysqlReader.GetValue(0).ToString().Trim();
                    string Name_Receptionist = MysqlReader.GetValue(1).ToString().Trim();
                    string Counsellor = MysqlReader.GetValue(2).ToString().Trim();
                    string Office = MysqlReader.GetValue(3).ToString().Trim();
                    string Type_Contact = MysqlReader.GetValue(4).ToString().Trim();
                    string Channel_Customer2Know = MysqlReader.GetValue(5).ToString().Trim();
                    string Date_Register = MysqlReader.GetValue(6).ToString().Trim();
                    ///
                    Label_Msg.Text = "重复！";
                    Label_Msg.Text += "咨询人:" + Name_Inquirer + ";  ";
                    Label_Msg.Text += "登记日期:" + Date_Register + ";  ";
                    Label_Msg.Text += "地区:" + Office + ";  ";
                    Label_Msg.Text += "顾问:" + Counsellor + ";  ";
                    Label_Msg.Text += "前台:" + Name_Receptionist + ";  ";
                    Label_Msg.Text += "客户接触方式:" + Type_Contact + ";  ";
                    Label_Msg.Text += "客户了解渠道:" + Channel_Customer2Know + "。 ";
                }
                if (nCol == 0)
                {
                    Label_Msg.Text = "无重复！";
                }
            }
            else
                Label_Msg.Text = "无重复！";

            MysqlReader.Close(); // 关闭sqDataReader
            MySqlconn.Close(); // 关闭数据库连接

        
        }
    }
}